package com.demo.function.spring.feign;

import com.demo.function.spring.feign.fallback.MiyaFeignClientFallback;
import com.demo.model.entity.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 使用fallback进行熔断降级
 * 注意，如果fallback和fallbackFactory同时赋值，优先使用fallback。同时也要配置是否开启熔断降级。
 * 使用Sentinel熔断降级，必须配置feign.sentinel.enabled=true
 */
@FeignClient(name = "service-miya", contextId = "miyaFeignClient", fallback = MiyaFeignClientFallback.class)
public interface MiyaFeignClient {

    @PostMapping("/modifyUserException")
    User modifyUserException(@RequestBody User user);

    @PostMapping("/modifyUser")
    User modifyUser(@RequestBody User user);
}
